package br.edu.turmavirtual;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

@SuppressLint("InflateParams")
public class TurmaListAdapter extends BaseAdapter {
	
	private List<Turma> lista;
	private Context contexto;
	
	public TurmaListAdapter(Context context,List<Turma> lista) {
		// TODO Auto-generated constructor stub
		this.contexto=context;
		this.lista=lista;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lista.size();
	}
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return lista.get(position);
	}
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@SuppressLint("ViewHolder")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Turma turma = lista.get(position);
		
		LayoutInflater inflater=(LayoutInflater)contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view=inflater.inflate(R.layout.turma_list, null);
		TextView cCodigo = (TextView)view.findViewById(R.id.txt_cod_turma);
		TextView cDescr = (TextView)view.findViewById(R.id.txt_descr_turma);
		
		cCodigo.setText(turma.getCodigo().toString());
		cDescr.setText(turma.getDescricao());
		
		return view;
		
		
	}

}
